package woa.sort.test20230210;

import java.util.Arrays;

/**
 * @author wangpeng
 * @date 2023/2/10 16:18
 */
public class SelectSort1 {

    public static void sort(int[] arr) {
        if (arr == null || arr.length == 0) {
            return;
        }

        for (int i = 0; i < arr.length - 1; i++) {
            int index = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[index]) {
                    index = j;
                }
            }
            int temp = arr[i];
            arr[i] = arr[index];
            arr[index] = temp;
        }
    }

    public static void main(String[] args) {
        int[] arr = {3,4,1,3,5,6,78,1,3,3,3,2};
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
